package com.funwell.server.utils;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class UrlUtils {

    private static final String SHORT_URL_API="http://api.t.sina.com.cn/short_url/shorten.json";

    public static String shortUrl(String url) {
        Map<String,String> req=new HashMap<String,String>();
        req.put("source","3271760578");
        req.put("url_long",url);
        String result= HttpUtils.sendGet(SHORT_URL_API,req);
        System.out.println(result.replace("[","").replace("]",""));
        JSONObject reqJson=JSONObject.parseObject(result.replace("[","").replace("]",""));
        return reqJson.getString("url_short");
    }
}
